<%@page import="java.awt.print.Printable"%>
<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="tags" tagdir="/WEB-INF/tags"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<html>
<head>
<%
response.setHeader("Cache-Control","no-store");
response.setHeader("Pragrma","no-cache");
response.setDateHeader("Expires",0);
%>
<title>_${customer.customerName}_拣货任务列表</title>
<script language="javascript" type="text/javascript" src="${ctx}/static/datepicker/WdatePicker.js"></script>
<script type="text/javascript">
 
  //领取任务 
  function takeTask(taskId){
	  $.ajax({
			type:'post',
			url:'${ctx}/pickTask/ajaxTakePickTask',
			data:{
				taskId:taskId
			},
			dataType:'json',
			success:function(data) {
			    if(data==true){
			      $("#queryForm").submit();
			    }else{
			      alert("网络繁忙，请稍后重试...");
			    }
			},
			error:function() {
				alert("网络繁忙，请稍后重试...");
			}
	   });
  }
  
//立即完成任务 
  function completeTask(taskId){
	  $.ajax({
			type:'post',
			url:'${ctx}/pickTask/ajaxCompletePickTask',
			data:{
				taskCode:taskId
			},
			dataType:'json',
			success:function(data) {
			    if(data==true){
			      window.location.reload();
			    }else{
			      alert("网络繁忙，请稍后重试...");
			    }
			},
			error:function() {
				alert("网络繁忙，请稍后重试...");
			}
	   });
  }
  //一件完成
  function isOneKeyComplete(id) {
	  
	  if(confirm("确定执行一键完成操作？")) {
		  	showBg();
			ajaxOneKeyComplete(id);
		}
}
  function ajaxOneKeyComplete(taskId){
	  $.ajax({
			type:'post',
			url:'${ctx}/carPickTask/ajaxOneKeyComplete',
			data:{
				taskId:taskId
			},
			dataType:'json',
			success:function(data) {
				closeBg();
			    var msg=data.msg;
			    if(msg=="task_finished"){
			    	alert("拣货完成!");
			    	window.location.reload();
			    }else if(msg=="recommit"){
					alert("数据重新提交,请检查!");
				}else if(msg=="error_status"){
			    	alert("已完成,请检查!");
			    	window.location.reload();
			    }else if(msg=="unPrintJH"){
			    	alert("未打印拣货单，不能完成任务!");
			    }else if(msg=="unPrintMD"){
			    	alert("尚有电子面单未打印，不能完成任务!");
			    }
			},
			error:function() {
				closeBg();
				alert("网络繁忙，请稍后重试...");
			}
	   });
  }

</script>
</head>

<body>
<div id="fullbg"></div>
<div id="dialog">
	<div>
		<img src="${ctx }/static/022.gif"></img>
	</div>
</div>

<section class="content">

<div class="row">
		<div class="col-md-12">

			<!-- Primary box -->
			<div class="box box-solid box-primary">
				<div class="box-header">
					<i class="fa fa-edit"></i>
					<h3 class="box-title">我的拣货任务</h3>
					<div class="box-tools pull-right">
						<button class="btn btn-primary btn-sm" data-widget="collapse">
							<i class="fa fa-minus"></i>
						</button>
					</div>
				</div>
				<div class="box-body">
	
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
	    <thead>
<!-- 			<th style="vertical-align: middle; color: white; " colspan="13" bgcolor="#8EB4CB">我的拣货任务</th> -->
		</thead>
		<thead><tr>
			    <th>序号</th>
			    <th>商家</th>
			    <th>仓库</th>
			    <th>任务</th>
			    <th>批次</th>
			    <th>运单类型</th>
			    <th>作业类型</th>
			    <th>拣货类型</th>
			    <th>订单数</th>
			    <th>创建时间</th>
			    <td>指派人</td>
			    <th>拣货人</th>
			    <th>任务状态</th>
			    <th>操作</th>
			</tr></thead>
		<tbody>
		<c:forEach items="${myPickTaskList}" var="t" varStatus="i">
			<tr>
			   <td>${i.count}</td>
			    <td>${t.customerCode}</td>
			   <td>${t.warehouseCode}</td>
			   <td><a href='${ctx}/orderMsg/v2_queryOrderMsg?_taskCode=${t.taskCode}' title="任务订单列表">${t.taskCode}</a></td>
			   <td><a href='${ctx}/workMsg/v2_workMsgDetail/${t.batchCode}'>${t.batchCode}</a></td>
			   <td>
			    <c:if test="${t.billType eq 'cbill'}">普通运单</c:if>
			    <c:if test="${t.billType eq 'ebill'}">电子运单</c:if>
			   </td>
			   <td>
			     <c:if test="${t.flowType eq 'prePrint'}">预先打单</c:if>
			     <c:if test="${t.flowType eq 'intimePrint'}">即时打单</c:if>
			  </td>
			   <td>
			     <c:if test="${t.pickType eq 'single'}">单件
			         <c:if test="${t.pickModel eq 'lamp'}"><font color=blue>【灯光拣选】</font></c:if>
			         <c:if test="${t.pickModel eq 'car'}"><font color=red>【推车拣选】</font></c:if>
			         <c:if test="${t.pickModel eq 'normal'}"><font color=blue>【分筐拣选】</font></c:if>
			     </c:if>
			     <c:if test="${t.pickType eq 'multi'}">多件
			         <c:if test="${t.pickModel eq 'lamp'}"><font color=blue>【灯光拣选】</font></c:if>
			         <c:if test="${t.pickModel eq 'car'}"><font color=red>【推车拣选】</font></c:if>
			         <c:if test="${t.pickModel eq 'normal'}"><font color=blue>【分筐拣选】</font></c:if>
			     </c:if>
			   </td>
			   <td>${t.orderQty}</td>
			   <td>${fn:substring(t.createTime,0,19)}</td>
			   <td>
			   	 <c:choose>
			   		<c:when test="${t.pickModel eq 'car'}">
			   		 	${t.assigner.realname }
			        </c:when>
			   		<c:otherwise>
			   			
			   		</c:otherwise>
			   	 </c:choose>     
			   </td>
			   <td>${t.picker.realname}</td>
			   <td>
			     <c:if test="${t.status eq '1'}">创建任务</c:if>
			     <c:if test="${t.status eq '2'}">已分配拣货任务</c:if>
			     <c:if test="${t.status eq '3'}">已拣货</c:if>
			     <c:if test="${t.status eq '4'}">已分配灯光拣选任务</c:if>
			     <c:if test="${t.status eq '5'}">已经灯光拣选</c:if>
			     <c:if test="${t.status eq '6'}">已分配包装任务</c:if>
			     <c:if test="${t.status eq '7'}">已包装</c:if>
			     <c:if test="${t.status eq '8'}">已分配发货任务</c:if>
			     <c:if test="${t.status eq '9'}">已发货</c:if>
			     <c:if test="${t.status eq '10'}">灯光拣选进行中...</c:if>
			     <c:if test="${t.status eq '11'}">推车拣选进行中...</c:if>
			     <c:if test="${t.status eq '12'}">拣货中...</c:if>
			   </td>
			   <td>
			   	  <c:choose>
			   		<c:when test="${t.fastFlag eq 1}">
			   			<c:if test="${loginerId eq  t.assigner.id}">
			   				 <a href="${ctx}/carPickTask/v2_toFastCarPickTaskPageNew/${t.id}/0" role="button"  class="btn btn-primary" >修改拣货人</a>
			   			</c:if>
			   			<c:if test="${loginerId ne  t.assigner.id}">
			   				 <a href="${ctx}/carPickTask/v2_toFastCarPickTaskPageNew/${t.id}/0" role="button"  class="btn btn-primary" >查看信息</a>
			   			</c:if>
			   				<a href="javascript:isOneKeyComplete(${t.id})" role="button"  class="btn btn-primary" >一键完成</a>
			        </c:when>
			   		<c:otherwise>
			   			  <c:if test="${t.status eq '2'}">
					         <a href="${ctx}/pickTask/v2_toPickTaskPage/${t.id}" role="button"  class="btn btn-primary" >开始任务</a>
					      </c:if>
					      <c:if test="${t.status eq '10'}">
					         <a href="${ctx}/pickTask/v2_toPickTaskPage/${t.id}" role="button"  class="btn btn-primary" >继续任务</a>
					      </c:if>
					      <c:if test="${t.status eq '11'}">
					         <a href="${ctx}/pickTask/v2_toPickTaskPage/${t.id}" role="button"  class="btn btn-primary" >继续任务</a>
					      </c:if>
					      <c:if test="${t.status eq '12'}">
					         <a href="${ctx}/pickTask/v2_toPickTaskPage/${t.id}" role="button"  class="btn btn-primary" >继续任务</a>
					      </c:if>
			   		</c:otherwise>
			   	 </c:choose>   
			      
			      <%-- <c:if test="${t.pickType eq 'single'}">
				      <shiro:hasPermission name="/pickTask/ajaxCompletePickTask">
							<input type="button" class="btn btn-primary" onclick="completeTask('${t.taskCode}');" value="立即完成"/>
					  </shiro:hasPermission>
				  </c:if> --%>
			   </td>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	</div>
	</div>
	</div>
	</div>
	<c:if test="${not empty message}">
		<div id="message" class="alert alert-success"><button data-dismiss="alert" class="close">×</button>${message}</div>
	</c:if>
	<!-- 查询结果 start -->
	<div class="row">
		<div class="col-md-12">

			<!-- Primary box -->
			<div class="box box-solid box-primary">
				<div class="box-header">
					<i class="fa fa-edit"></i>
					<h3 class="box-title">未分配的拣货任务</h3>
					<div class="box-tools pull-right">
						<button class="btn btn-primary btn-sm" data-widget="collapse">
							<i class="fa fa-minus"></i>
						</button>
					</div>
				</div>
				<div class="box-body">
	
	<!-- 未分配的拣货任务 -->
	<form class="form-search" id="queryForm" method="post" action="${ctx}/pickTask/v2_queryPickTaskList" style="margin-top: 10px;">
			 	
				<div class="form-group row">
				<div class="col-sm-3">
					<div class="input-group col-sm-12">
						<span class="input-group-text"> 商家用户： </span> 
						
						  <select class="form-control"  id="_customerCode" name="_customerCode"  value="${param._customerCode}" onchange="ajaxAreaGroup(this,'_warehouseCode');" >
						        <option value=""></option>
								<c:forEach items="${customerList}" var="customer">
									<option value="${customer.customerCode}"
									  <c:if test="${_customerCode eq customer.customerCode }">selected=selected</c:if>
									>${customer.customerName}</option>
								</c:forEach>
						</select> 
					</div>
				</div>
				<div class="col-sm-2">
					<div class="input-group col-sm-12">
						<span class="input-group-text"> 作业仓库： </span> 
						
						 <select  name="_warehouseCode"  id="_warehouseCode" value="${param._warehouseCode}"  class="form-control">
							<option value=""></option>
							<c:forEach items="${warehouseList}" var="w" >
							   <option value="${w.groupCode}" 
							   <c:if test="${_warehouseCode eq w.groupCode }">selected=selected</c:if>
							   >${w.groupName}</option>
						   </c:forEach>
						</select>
					</div>
				</div>
				
				<div class="col-sm-2">
					<div class="input-group col-sm-12">
						<span class="input-group-text"> 订单类型： </span> 
						 <select class="form-control"  id="_pickType" name="_pickType">
						        <option value="" <c:if test="${param._pickType eq ''}">selected="selected"</c:if>>全选</option>
						        <option value="single" <c:if test="${param._pickType eq 'single'}">selected="selected"</c:if>>单件</option>
						        <option value="multi" <c:if test="${param._pickType eq 'multi'}">selected="selected"</c:if>>多件</option>
						</select>
					</div>
				</div>
				
				<!-- begin 增加任务编号查询条件 by rongfei.zhang -->
				<div class="col-sm-2">
					<div class="input-group col-sm-12">
						<span class="input-group-text">任务编号:</span> 
						<input type="text" id="_taskCode" name="_taskCode" value="${_taskCode}" class="form-control span3" >
					</div>
				</div>
				<!-- end 增加任务编号查询条件 by rongfei.zhang -->
				
				<div class="col-sm-3">
			    <button class="btn btn-primary" type="submit" style="margin-left: 10px;">搜索</button>
			    
			    <!-- add 20161107 默认不加载，手动加载标记 -->
				<input type="text" id="_manualSearch" name="_manualSearch" value="manualSearch" hidden="true"/>
				<input type="text" id="_num" name="_num" value="2000" hidden="true"/>
				<span style="color: red" >${_manualSearchTip }</span>
			    <!-- end 20161107 默认不加载，手动加载标记 -->
			    
			    </div>
		   
		   </div> </form>
	<table class="table table-striped table-bordered table-condensed" style="margin-top: 0px;">
		<thead>
<!-- 			<th style="vertical-align: middle; color: white; " colspan="13" bgcolor="#8EB4CB">未分配的拣货任务</th> -->
		</thead>
		<thead><tr>
			    <th>序号</th>
			    <th>商家</th>
			    <th>作业仓库</th>
			    <th>任务编号</th>
			    <th>批次编号</th>
			    <th>运单类型</th>
			    <th>作业类型</th>
			    <th>订单类型</th>
			    <th>订单数量</th>
			    <th>创建时间</th>
			    <th>拣货执行人</th>
			    <th>任务状态</th>
			    <th>操作</th>
			</tr></thead>
		<tbody>
		<c:forEach items="${untakedPickTaskList}" var="t" varStatus="i">
			<tr>
			   <td>${i.count}</td>
			    <td>${t.customer.customerName}</td>
			   <td>${t.warehouse.groupName}</td>
			   <td>${t.taskCode}</td>
			   <td>${t.batchCode}</td>
			   <td>
			    <c:if test="${t.billType eq 'cbill'}">普通运单</c:if>
			    <c:if test="${t.billType eq 'ebill'}">电子运单</c:if>
			   </td>
			   <td>
			     <c:if test="${t.flowType eq 'prePrint'}">预先打单</c:if>
			     <c:if test="${t.flowType eq 'intimePrint'}">及时打单</c:if>
			  </td>
			   <td>
			     <c:if test="${t.pickType eq 'single'}">单件
			         <c:if test="${t.pickModel eq 'lamp'}"><font color=blue>【灯光拣选】</font></c:if>
			         <c:if test="${t.pickModel eq 'car'}"><font color=red>【推车拣选】</font></c:if>
			         <c:if test="${t.pickModel eq 'normal'}"><font color=blue>【分筐拣选】</font></c:if>
			     </c:if>
			     <c:if test="${t.pickType eq 'multi'}">多件
			         <c:if test="${t.pickModel eq 'lamp'}"><font color=blue>【灯光拣选】</font></c:if>
			         <c:if test="${t.pickModel eq 'car'}"><font color=red>【推车拣选】</font></c:if>
			         <c:if test="${t.pickModel eq 'normal'}"><font color=blue>【分筐拣选】</font></c:if>
			     </c:if>
			   </td>
			   <td>${t.orderQty}</td>
			   <td>${fn:substring(t.createTime,0,19)}</td>
			   <td></td>
			   <td><font color=red>未分配拣货任务</font></td>
			   <td>
			   		<c:if test="${t.pickModel eq 'car'}">
			   		 	<a href="${ctx}/carPickTask/v2_toFastCarPickTaskPageNew/${t.id}/1" role="button"  class="btn btn-primary" >快捷领取</a>
			        </c:if>
			   		<input type="button" class="btn btn-primary" onclick="takeTask('${t.id}');" value="领取任务"/>
			   </td>
			</tr>
		</c:forEach>
		</tbody>
		
	</table>
	
	</div>
	</div>
	</div>
	</div>
</section>

</body>
</html>
